package com.ryl.yomall.task;

/**
 * @Date 11:28
 * @Author ryl
 * 定时器
 */

import com.ryl.yomall.rabbitmq.constant.MQConstant;
import com.ryl.yomall.rabbitmq.service.RabbitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@EnableScheduling
@Slf4j
@Component
public class ScheduledTask {
    @Autowired
    private RabbitService rabbitService;

    /**
     * 每天凌晨1点执行
     */
    //@Scheduled(cron = "0 0 1 * * ?")
    @Scheduled(cron = "0/5 * * * * ? ")
    public void task1() {
        rabbitService.sendMessage( MQConstant.EXCHANGE_DIRECT_TASK, MQConstant.ROUTING_TASK_1, "");

    }
    /**
     * 每天20点发送mq消息,清空缓存
     */
    @Scheduled(cron = "0 0 20 * * ?")
    public void task18() {
        log.info("task18");
        rabbitService.sendMessage(MQConstant.EXCHANGE_DIRECT_TASK, MQConstant.ROUTING_TASK_18, "");
    }


}
